package cn.hj.basic.intercepter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcconfigurer implements WebMvcConfigurer {

    @Autowired
    private  LoginIntercepter loginIntercepter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginIntercepter)
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns("/login/**",//放行哪些资源
                        "/user/register/phone",
                        "/fastDfs/**",
                        "/shop/settlement",
                        "/verifycode/**",
                        "/notify")//支付宝支付成功后的异步回调地址
                .excludePathPatterns("/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**");

    }
}
